//
//  CalculatorEngine.h
//  iCalculator
//
//  Created by Stephen Houser on 9/7/07.
//  Copyright 2007 __MyCompanyName__. All rights reserved.
//

#import "Calculator_Prefix.h"

#define INPUT_SIZE	100

// Change the int to float when _objc_msgSend_fpret is fixed
#define FLOAT_HACK	int

@interface CalculatorEngine : NSObject {

	// These are the two registers we use for doing
	// all our computations.
	float	registerX;	// the X register
	float	registerA;	// the Accumulator

	// I forget what this register is for.
	float	memory;

	// Here we store the pending binary operation
	// and the last operation we did for repeat =s
	NSString * pendingOperation;
	NSString * lastOperation;
	
	// Does registerA contain a result from a previous
	// computation/operation? Used so we can repeat
	// operations with =s and +-/*s
	BOOL isResult;
}


- (id) init;

// here is where you get the current result of operations
- (NSString *) getCurrentResult;

// commands from views/controllers come in here
- (void) sendCommand: (NSString *) command;
// triggered by keypress events
- (void) enterNumber: (NSString *) number;
- (void) enterBinaryOperator: (NSString *)operator;
- (void) enterEquals;
- (void) enterPercent;
- (void) enterClearEntry;
- (void) enterClearAll;
- (void) memoryClear;
- (void) memoryAdd;
- (void) memorySubtract;
- (void) memoryRecall;

// and somewhere we actually evaluate things
- (void) evaluateOperation;
// triggered by evaluateOperation
- (void) operationAdd;
- (void) operationSubtract;
- (void) operationMultiply;
- (void) operationDivide;

// debugging
- (void) dump: (NSString *) message;
@end

